/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';

@grid-prefix-cls: ~'@{css-prefix}grid';
@grid-header-prefix-cls: ~'@{css-prefix}grid-header';
@grid-cell-prefix-cls: ~'@{css-prefix}grid-cell';
@grid-checkbox-prefix-cls: ~'@{css-prefix}grid-checkbox';

.@{grid-prefix-cls}__header-wrapper {
  background-color: var(--tv-Grid-header-bg-color);

  // x轴方向虚拟滚动适配线
  .@{grid-prefix-cls}__repair {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 0;
    z-index: 1;
    border-bottom: 1px solid transparent;
  }
}

.@{grid-header-prefix-cls}__column {
  position: relative;
  font-size: var(--tv-Grid-font-size);
  color: var(--tv-Grid-header-text-color);

  // 去掉最后一个竖线
  &:nth-last-of-type(2) {
    .@{grid-prefix-cls}-resizable.is__line:before {
      width: 0;
    }
  }

  // 在表格个性化场景，动态的设置冻结列，这里需要在非冻结列情况下消除之前设置的left和right样式，并提升权重覆盖style属性
  &:not(.fixed__column) {
    left: unset !important;
    right: unset !important;
  }

  &.col__title-checked {
    background-color: var(--tv-Grid-col-header-active-bg-color);
    border: 1px solid var(--tv-Grid-col-header-active-border-color);

    .@{grid-prefix-cls}-edit-icon {
      &.@{grid-prefix-cls}-icon__edit-outline {
        &:before {
          background-color: #dcdcdc;
        }
      }
    }
  }

  &.col__ellipsis {
    .@{grid-prefix-cls}-edit-icon {
      flex-shrink: 0;
    }
  }

  .@{grid-prefix-cls}-required-icon {
    color: var(--tv-Grid-header-required-icon-color);
    line-height: 1;
    font-size: var(--tv-Grid-font-size);
    align-self: baseline;
    display: inline-block;

    &:before {
      content: '*';
      width: 10px;
      height: 10px;
      display: block;
    }
    + .@{grid-prefix-cls}-cell-text {
      width: auto;
    }
  }

  .@{grid-prefix-cls}-cell-text {
    width: auto;
  }

  .@{grid-prefix-cls}-edit-icon {
    font-size: var(--tv-Grid-icon-size);
    margin-left: 4px;
    flex-shrink: 0;
    fill: var(--tv-Grid-icon-color);
    + .@{grid-prefix-cls}-cell-text {
      width: auto;
      order: -1;
    }
  }

  .@{grid-prefix-cls}-thead-partition,
  .@{grid-prefix-cls}-resizable {
    position: absolute;
    right: 0;
    transform: translateX(50%);
    bottom: 0;
    top: 0;
    margin: auto;
    width: 14px;
    height: 100%;
    text-align: center;
    user-select: none;

    @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
      margin: 0;
    }

    &.is__line {
      &:before,
      &:after {
        content: '';
        display: inline-block;
        vertical-align: middle;
      }

      &:before {
        width: 1px;
        height: 16px;
        background-color: var(--tv-Grid-header-divider-color);
      }

      &:after {
        width: 0;
        height: 100%;
      }
    }
  }

  .@{grid-prefix-cls}-resizable {
    cursor: col-resize;
  }
}

.@{grid-prefix-cls}__header {
  .@{grid-prefix-cls}-cell-text {
    font-weight: var(--tv-Grid-header-font-weight);
  }
  .@{header-suffix} {
    position: relative;
    min-height: 16px;

    .suffix-icon-1 {
      position: absolute;
      right: 12px;
    }

    .suffix-icon-0 {
      position: absolute;
      right: 0;
    }
  }
}

.@{grid-prefix-cls} {
  th.col__selection > .@{grid-cell-prefix-cls} {
    position: relative;

    & > .selection-dropdown-wrapper {
      position: absolute;
      left: calc(50% + 22px);
      top: 50%;
      transform: translateX(-50%) translateY(-50%);

      .tiny-svg {
        fill: var(--tv-Grid-icon-color);
        vertical-align: middle;
      }
    }
  }
}
